const express = require("express");

const app = express();

app.get("/user", (req, res) => {
  res.send({ name: "lmx", age: 18, gender: "male" });
});

app.post("/user", (req, res) => {
  res.send("Access successful");
});

//获取url中携带的查询参数
app.get("/", (req, res) => {
  console.log(req.query);
  res.send(req.query);
});

// 动态传参
app.get("/user/:id", (req, res) => {
  console.log(req.params);
  res.send(req.params);
});
app.listen(8080, () => {
  console.log("express server running at http://127.0.0.1:8080");
});
